-- @owner: kyleze
-- @date: 2024-10-20
-- @testpoint: bit作为对象名测试,部分合理报错

--prestep1:切换B库;expect:执行成功
@conn PrimaryDbBmode;
show sql_compatibility;

--step1:作为列名 expect:成功
drop table if exists bit_test cascade;
create table bit_test(bit bit);
insert into bit_test values(b'0');

--step2:作为索引名 expect:成功
create index on bit_test(bit);
drop table if exists bit_test cascade;

--step3:作为表名 expect:成功
drop table if exists bit cascade;
create table bit(bit bit);
insert into bit values(b'1');
select * from bit;
drop table if exists bit cascade;

--step4:作为数据库名 expect:成功
drop database if exists bit;
create database bit;
drop database bit;

--step5:作为外部数据源名 expect:成功
drop data source if exists bit;
create data source bit;
drop data source bit;

--step6:作为自定义函数名，expect:报错
create or replace function bit(c1 bit(666))
returns bit(666)
as  $$
begin
    return c1;
end;
$$
language plpgsql;
/

--step7:作为存储过程名 expect:报错
create or replace procedure bit(p1 in bit(666)) as
begin
    insert into t_bit_0023 values ('0000');
end;
/

--step8:作为角色名 expect:成功
drop role if exists bit;
create role bit with password 'gauss@123' valid until '2001-12-12';
drop role bit;

--step9:作为用户组名 expect:成功
drop group if exists bit;
create group bit with password 'gauss@123';
drop group bit;

--step10:作为模式名 expect:成功
drop schema if exists bit;
create schema bit;
drop schema bit;

--step11:作为序列名 expect:成功
create sequence public.bit start 100 cache 50;
drop sequence public.bit;

--step12:作为用户名 expect:成功
drop user if exists bit;
CREATE USER bit PASSWORD 'Bigdata@123';drop user bit;

--step13:作为前置条件名 expect:成功
drop table if exists bit_test cascade;
create table bit_test(cid int,fid int);

--step14:作为游标号名 expect:成功
start transaction;
cursor bit for select * from bit_test order by 1;
close bit;
end;

--step15:清理环境 expect:成功
drop table if exists bit_test cascade;
